@mixin webfont-icon ($color, $mobile-color, $font-size, $mobile-font-size) {
  text-align: center;
  &:before {
    font-size: $font-size;
    color: $color;
    font-family: "icons";

    @media #{$mobile} {
      font-size: $mobile-font-size;
      color: $mobile-color;
    }
  }
}

@media #{$mobile} {
  // Only show the menu button on mobile
  body>.menu-button {
    background-color: $topbar-background-color;
    display: inline-block;
    vertical-align: top;
    background-image:url(/menu.svg);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 32px 32px;
    width: 48px;
    height: 48px;
    padding: 4px;
    color: transparent;
    cursor: pointer;
    border-right: 1px solid #666;
    position: fixed;
    left: 0;
    top: 0;
    &:hover {
      background-color: $topbar-background-color-hover;
    }
    &.expanded {
      z-index: 101;
    }
  }
}

body>.topbar-update {
  @include unstyled-button();
  position: fixed;
  width: 100%;
  height: 32px;
  text-align: center;
  background-color: #622;
  color: #fcc;
  z-index: 1000;
  cursor: pointer;
  font-weight: bold;
  line-height: 32px;

  @media #{$mobile} {
    line-height: 24px;
    height: 48px;
    left: 0;
    right: 0;
  }
}

body>.topbar {
  position: fixed;
  top: 0;
  margin: 0;
  padding: 0;
  width: 100%;
  text-align: left;

  line-height: 32px;
  height: 32px;
  background-color: $topbar-background-color;
  color: #ccc;

  // Using 0 rather than CSS default ("auto") allows introjs to highlight elements in the topbar.
  z-index: 0;

  &.standalone {
    display: none;
  }

  @media #{$mobile} {
    line-height: 48px;
    height: 48px;
    // TODO(now): figure out if these colors should be different
    //background-color: #eee;
    //color: black;
    transition: height 0.2s;
    overflow: hidden;

    &.expanded {
      height: 100%;
      box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.2);
      // We avoid placing a z-index on the topbar when not expanded, lest modal dialogs
      // that don't live at the same depth in the DOM be made unable to cover the topbar.
      z-index: 100;
    }
  }

  %topbar-button {
    // Common styling for buttons in the topbar (on desktop).

    @include unstyled-button();

    @media #{$desktop} {
      display: block;
      height: 100%;
      margin: 0;
      padding: 0;
      overflow: hidden;

      &:hover {
        background-color: $topbar-background-color-hover;
      }
    }
  }

  %icon-button {
    // Common styling for topbar buttons that are displayed as a bare icon with no text label
    // (on desktop).

    @extend %topbar-button;

    @media #{$desktop} {
      background-position: center;
      background-repeat: no-repeat;
      background-size: 24px 24px;
      color: transparent;  // hide text
      width: 32px;
      height: 32px;
      position: relative;
    }
  }

  %mobile-icon-button {
    // Common styling for topbar buttons that are displayed as a bare icon with no text label
    // (on mobile).

    @include unstyled-button();

    @media #{$mobile} {
      display: block;
      margin: 0;
      padding: 0;
      overflow: hidden;
      background-position: center;
      background-repeat: no-repeat;
      background-size: 40px 40px;
      color: transparent;  // hide text
      width: 48px;
      height: 48px;

      &:hover {
        background-color: $topbar-background-color-hover;
      }
    }
  }

  %hamburger-menu-item {
    // Common styling for topbar items that are displayed as a hamburger menu item on mobile.
    @media #{$desktop} {
      height: $topbar-height-desktop;
    }

    @media #{$mobile} {
      display: block;
      width: 100%;
      background-position: 8px center;
      background-size: 32px 32px;
      background-repeat: no-repeat;
      background-color: transparent;
      text-align: left;
      padding-left: 48px;
      font-size: 14pt;
      height: $topbar-height-mobile;
      font-weight: normal;
      text-decoration: none;

      &:hover {
        background-color: $topbar-background-color-hover;
      }
    }
  }

  >ul>li, >ul>ul>li, >ul>ul>ul>li {
    // Each "item" in the topbar is an <li>, so this style applies to all of them.

    display: inline-block;
    list-style-type: none;
    vertical-align: top;

    >button.show-popup {
      @extend %topbar-button;
    }

    @media #{$mobile} {
      display: block;
      float: none;
      width: 100%;
      height: 49px;
      border-bottom: 1px solid #ddd;
      padding: 0;
    }
  }

  >.menubar {
    padding-left: 0;
    margin-left: 0;
    border-bottom: 1px solid $topbar-border-color;
    overflow: hidden;
    @media #{$desktop} {
      height: $topbar-height-desktop;
      &.shrink-desktop {
        >.home-button {
          width: $navbar-width-desktop-shrunk !important;
          >a {
            width: $navbar-width-desktop-shrunk !important;
            padding-right: 0;
          }
        }
      }
    }

    >.home-button {
      @media #{$desktop} {
        width: $navbar-width-desktop;
        transition: width 0.2s;
        float:left;
        overflow: hidden;

        >a {
          @include overflow-ellipsis();
          color: inherit;
          margin: 0px;
          text-decoration: none;
          height: $topbar-height-desktop;
          padding-left: $navbar-width-desktop-shrunk;
          padding-right: 8px;

          background-image: url("/icon.png");
          background-repeat: no-repeat;
          background-position: 16px center, 6px 24px;
          background-size: auto, 16px 8px;

          &:hover {
            background-color: $topbar-background-color-hover;
            color: $topbar-foreground-color-hover;
          }
        }
      }

      @media #{$mobile} {
        // Hide home link -- it's not very useful anyway.
        display: none;
      }
    }

    >.title {
      padding-left: 8px;
      overflow: hidden;
      @media #{$desktop} {
        // Heuristically try to prevent the title from bumping everything else off the top bar.
        // The size of 700px was empirically found to provide enough space for "everything else".
        max-width: calc(100% - 700px);
        border-left: 1px solid #666;
      }
      @media #{$mobile} {
        width: 100%; // needs to span the whole row because the border-bottom is needed to draw
                     // the horizontal rule when the menu is expanded
        background-color: $topbar-background-color;
        color: $topbar-foreground-color;
        padding-left: 56px;
        font-size: 120%;
      }

      >div.editable {
        white-space: nowrap;
        text-overflow: ellipsis;  // Doesn't seem to work since size is dynamic. Left here in vain.
        overflow: hidden;
        display: inline-block;
        padding: 0 8px;
        margin-left: -8px;
        @media #{$desktop} {
          min-height: $topbar-height-desktop;
        }
        @media #{$mobile} {
          min-height: $topbar-height-mobile;
          max-width: calc(100% - 150px);
        }

        &:hover {
          cursor: pointer;
          color: $topbar-foreground-color-hover;
          background-color: $topbar-background-color-hover;
        }

        .main-title {
          height: $topbar-height-desktop - 8px;
          line-height: $topbar-height-desktop - 8px;
          @media #{$mobile} {
            height: $topbar-height-mobile - 12px;
            line-height: $topbar-height-mobile - 12px;
          }
        }

        .subtitle {
          color: #9b9b9b;
          height: 10px;
          line-height: 10px;
          font-size: 10px;
          margin-top: -4px;

          @media #{$mobile} {
            height: 12px;
            line-height: 12px;
            font-size: 12px;
            margin-top: -4px;
          }
        }
      }
    }

    >.grain-size {
      @media #{$mobile} {
        display: none;
      }
    }

    >.share>button.show-popup {
      @extend %topbar-button;
      @extend %hamburger-menu-item;

      @extend .icon-share;
      &::before {
        @extend .icon;
      }

      @media #{$desktop} {
        background-position: 2px center;
        color: #cccccc; // Have the text match the icon.
                        // This is the single place the button text is visible.
        padding-left: 8px;
        padding-right: 8px;
        height: 32px;
        line-height: 32px;
        font-size: 12pt;
        &::before {
          font-size: 32px;
          vertical-align: top;
        }
      }
      @media #{$mobile} {
        background-position: 10px center;
        position: relative;
        &::before {
          position: absolute;
          left: 8px;
          top: 8px;
          font-size: 32px;
        }
      }
    }

    // Buttons for misc grain actions.
    >li>button.grain-button, >.webkey>button.show-popup {
      @extend %icon-button;
      @extend %hamburger-menu-item;
    }
    >.delete>button    { background-image: url("/trash.svg"); }
    >.debug-log>button { background-image: url("/debug.svg"); }
    >.backup>button    { background-image: url("/download.svg"); }
    >.restart>button   { background-image: url("/restart.svg"); }
    >.webkey>button    { background-image: url("/key.svg"); }
    >.who-has-access img { width: 20px; }

    >.admin-alert {
      @media #{$desktop} {
        float: right;
      }

      @media #{$mobile} {
        position: fixed;
        top: 0;
        right: 48px;
        width: 48px;
        height: 49px;
        text-align: center;
      }

      >button.show-popup {
        @extend %icon-button;
        @extend %mobile-icon-button;
      }

      .alert {
        background-color: $sandstorm-purple-color;
        color: white;
        text-decoration: none;

        display: inline-block;
        padding-left: 8px;
        padding-right: 8px;
        margin-right: 8px;
      }

      .alert.countdown-second,
      .alert.countdown-now {
        // Turn red when there's less than a minute left.
        background-color: #e82538;
      }

      a:hover {
        background-color: #9d3aa5;
      }
    }

    >.notifications {
      @media #{$desktop} {
        float: right;
      }

      @media #{$mobile} {
        position: fixed;
        top: 0;
        right: 0;
        width: 48px;
        height: 49px;
        background-color: $topbar-background-color; // needed to cover an overflowing title
      }

      >button.show-popup {
        @extend %icon-button;
        @extend %mobile-icon-button;

        @include webfont-icon(#CCCCCC, #CCCCCC, 24px, 40px);

        >.count {
          display: block;
          position: absolute;
          top: 16px;
          left: 16px;
          width: 16px;
          height: 16px;
          background-color: red;
          border-radius: 8px;
          color: white;
          line-height: 16px;
          text-align: center;
          font-size: 8pt;

          @media #{$mobile} {
            top: 24px;
            left: 24px;
          }
        }
      }
    }

    >.account, >.login {
      >button.show-popup {
        @extend %hamburger-menu-item;
        position: relative;
        >.profile-picture {
          position: absolute;
          display: block;
          background-size: contain;
          background-repeat: no-repeat;
          background-position: center;
          @media #{$desktop} {
            width: 24px;
            height: 24px;
            top: 4px;
            left: 4px;
          }
          @media #{$mobile} {
            width: 32px;
            height: 32px;
            left: 8px;
            top: 8px;
          }
        }
      }

      @media #{$desktop} {
        float: right;
        display: block;

        >button.show-popup {
          padding-left: 8px;
          padding-right: 8px;
          display: block;
          &.has-picture {
            padding-left: 32px;
          }
        }
      }

      @media #{$mobile} {
        >button.show-popup {
          font-weight: normal;
        }
      }
    }
  }

  >.navbar {
    @media #{$desktop} {
      .navbar-shrink-item {
        &:hover {
          button.navbar-shrink {
            background-color: #717171;
            border-color: #343434;
          }
        }
      }

      button.navbar-shrink {
        @include unstyled-button();
        @include webfont-icon(#CCCCCC, #CCCCCC, 28px, 28px);
        display: block;
        width: 100%;
        height: $navbar-shrink-button-height;
        border: 0px solid #303030;
        border-left-width: ($navbar-width-desktop - $navbar-width-desktop-shrunk);
        background-color: #606060;
        color: #ddd;
        text-align: center;
        line-height: $navbar-shrink-button-height;
        padding: 0;

        transition: border-left-width 0.2s;

        &.shrunk {
          &::before {
            display: inline-block; // this is needed to allow transforms.
            transform: rotate(180deg);
          }
        }
      }

      &.shrink-desktop {
        // !important used to override other classes that might assign e.g. display: block
        width: $navbar-width-desktop-shrunk !important;

        button.navbar-shrink {
          border-left-width: 0;
        }
        button.close-button {
          display: none !important;
        }
        >ul.navbar-grains>li.navitem-grain a {
          padding-right: 0 !important;
        }
        .demo-notice {
          p { font-size: 0 !important; padding: 0px; }
          span { display: none !important; }
          button { display: none !important; }
          a { display: none !important; }
        }
        .demo-timer {
          p { font-size: 0 !important; padding: 4px !important; }
        }
      }
      &.hide-desktop {
        display: none;
      }

      transition: width 0.2s;
    }
    @media #{$mobile} {
      li.navbar-shrink-item {
        display: none;
      }
    }
    @media #{$desktop} {
      position: fixed;
      top: $topbar-height-desktop;
      bottom: 0px;
      left: 0px;
      width: $navbar-width-desktop;
      background-color: #303030;
      color: #606060;
      li {
        display: block;
        position: relative;
        border-bottom: 1px solid $topbar-border-color;
        margin: 0;
        list-style-type: none;

        &.navitem-open-grain, &.navitem-create-grain, &.navitem-grain {
          a {
            display: block;
            min-height: 32px;
            padding-left: $navbar-width-desktop-shrunk;
            text-decoration: none;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            &, &:visited, &:active, &:hover {
              color: inherit;
            }
          }
        }
        &.navitem-grain {
          line-height: 32px;
          height: 32px;
        }
        &.navitem-open-grain, &.navitem-create-grain {
          display: block;
          position: relative;
          background-repeat: no-repeat;
          background-position: (($navbar-width-desktop-shrunk - 24px) / 2) center;
          background-size: 24px 24px;
          font-size: 150%;
          line-height: 48px;
          height: 48px;
          background-color: $topbar-background-color;
          color: $topbar-foreground-color;
          &:hover {
            background-color: $topbar-background-color-hover;
            color: $topbar-foreground-color-hover;
          }
          &.current, &.current:hover {
            background-color: $topbar-background-color-active;
            color: $topbar-foreground-color-active;
          }
        }
        &.navitem-open-grain {
          background-image: url('/open-grain.svg');
          &.current, &.current:hover {
            background-image: url('/open-grain-m.svg');
          }
          border-bottom: none;
        }
        &.navitem-create-grain {
          background-image: url('/apps.svg');
          &.current, &.current:hover {
            background-image: url('/apps-m.svg');
          }
        }
        &.navbar-shrink-item {
          border: none;
          height: auto;
          width: auto;
        }
        &.navitem-demo-timer {
          position: absolute;
          bottom: 0;
          height: auto;
          width: 100%;
        }
      }
    }
    @media #{$mobile} {
      position: relative;
      li {
        font-size: 14pt;
        line-height: 48px;
        height: 48px;
        display: block;
        position: relative;
        border-bottom: 1px solid #676767;
        margin: 0;
        &.navitem-open-grain, &.navitem-create-grain, &.navitem-grain {
          a {
            display: block;
            padding-left: 48px;
            text-decoration: none;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            &, &:visited, &:active, &:hover {
              color: inherit;
            }
          }
        }
        &.navitem-open-grain, &.navitem-create-grain {
          background-repeat: no-repeat;
          background-position: 12px center;
          background-size: 24px 24px;
        }
        &.navitem-open-grain {
          background-image: url('/open-grain.svg');
        }
        &.navitem-create-grain {
          background-image: url('/apps.svg');
        }
        &.navitem-demo-timer {
          height: auto;
        }
      }
    }
    margin: 0;
    padding: 0;
    >ul.navbar-grains {
      margin: 0;
      padding: 0;
      bottom: 0px;
      left: 0px;
      width: 100%;
      //height: 100%; // TODO: fix this, it should be 100% - (height of Open + New)
      overflow-y: auto;
      >li.navitem-grain {
        a {
          padding-right: 32px;
          transition: padding-right 0.2s;

          // Stack above .app-icon so the icon doesn't block clicks.
          position: relative;
          z-index: 1;
        }
        background-color: $topbar-background-color;
        color: $topbar-foreground-color;
        &:hover {
          background-color: $topbar-background-color-hover;
          color: $topbar-foreground-color-hover;
        }
        &.unread {
          background-color: $topbar-background-color-unread;
          color: $topbar-foreground-color-unread;
        }
        &.unread:hover {
          background-color: $topbar-background-color-unread-hover;
        }
        &.current, &.current:hover {
          background-color: $topbar-background-color-active;
          color: $topbar-foreground-color-active;
        }
        .app-icon {
          @extend %pseudo-img-tag;
          position: absolute;
          top: 4px;
          left: (($navbar-width-desktop-shrunk - 24px) / 2);
          width: 24px;
          height: 24px;
        }
        .notification-count {
          position: absolute;
          display: block;
          top: 16px;
          left: 28px;
          width: 16px;
          height: 16px;
          background-color: red;
          color: white;
          border-radius: 50%;
          z-index: 2;
          font-size: 12px;
          font-weight: bold;
          line-height: 16px;
          text-align: center;
        }
        .close-button {
          @include unstyled-button();
          @extend %pseudo-img-tag;
          position: absolute;
          top: 1px;
          right: 0px;
          width: 24px;
          height: 24px;
          margin: 2px;
          display: block;
          background-image: url("/close.svg");
          border: 1px solid transparent;
          border-radius: 4px;
          &:hover {
            border: 1px solid $topbar-foreground-color-hover;
          }
          z-index: 2;  // Stack above <a>.
        }
      }
    }

    li.navitem-demo-notice {
      height: auto !important;
    }
  }

  .demo-notice {
    width: 100%;
    overflow: hidden;

    p {
      color: white;
      padding: 8px;
      margin: 0;
      margin-bottom: 8px;
      line-height: normal;
      font-size: 14px;
      transition: font-size 0.2s;

      a.get-sandstorm-button {
        margin-top: 6px;
        display: block;
        @extend %button-base;
        background-color: #606060;
        color: white;
        &:hover {
          background-color: #717171;
        }
      }
    }

    button {
      display: block;
      width: 100%;
      text-align: center;
      margin-top: 6px;
      margin-bottom: 4px;
    }

    .subtext {
      font-size: 12px;
      color: $topbar-foreground-color;
    }
  }

  .demo-timer {
    p {
      margin: 0;
      padding: 4px;
      color: $topbar-foreground-color;
      font-size: 14px;
    }
  }

  .countdown {
    display: block;
    font-size: 30px;
    font-weight: bold;
    color: #a0a0a0;
    text-align: center;
    border: 1px solid $topbar-foreground-color;
    border-radius: 4px;

    &.urgent {
      color: #f00;
    }
  }
}

// =======================================================================================

body>.popup.who-has-access {
  img.spinner {
    display: block;
    margin: auto;
    width: 48px;
    height: 48px;
  }

  >.frame-container {
    width: 500px;
  }
}

body>.popup.modal {
  background-color: rgba(0, 0, 0, 0.5);

  >.frame-container {
    width: 600px;

    position: static;
    margin: 64px auto 32px;
    font-size: 20px;
    max-width: 90%;
    border: 1px solid #ccc;
    overflow-y: auto;
  }
}
.demo-startup-modal {
  .modal-dialog {
    margin-top: 80px;
    .modal-content {
      // max-height: calc(100vh - 64px);
      // overflow-y: auto;
      padding: 0px;

      div.top {
        background: #2D1E3A url('/demo-logo-bg.svg') no-repeat;
        width: 100%;
        background-position: center;
        background-size: auto 250px;
        height: 250px;
        top: 0px;
        left: 0px;
        width: 100%;
        padding-top: 25px;

        >.header {
          color: white;
          font-size: 23px;
          font-weight: normal;
          text-align: center;
        }

        >.body {
          color: #C5B0CC;
          font-size: 23px;
          font-weight: normal;
          text-align: center;
          margin-top: 10px;
        }
        >.start {
          font-size: 23px;
          width: 90%;
          margin: auto 5%;
          height: 48px;
        }
      }

      div.bottom {
        padding: 10px 10px 15px 30px;
        font-size: 16px;
      }
    }
  }
}

body>.popup {
  // Popup windows hang off the topbar, usually appearing when a topbar item is clicked.

  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100000;

  @media #{$mobile} {
    // Gray the background on mobile.
    background-color: rgba(0, 0, 0, 0.5);
  }

  >.frame-container {
    max-height: calc(100vh - 64px);
    line-height: normal;
    white-space: normal;
    background-color: white;
    font-weight: normal;
    color: black;
    box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.2);
    border-left: 1px solid #E0E0E0;
    border-right: 1px solid #E0E0E0;
    border-bottom: 1px solid #E0E0E0;

    >.frame {
      position: relative;
      overflow: hidden;  // prevent margin-collapse
      >.close-popup {
        display: block;
        position: absolute;
        top: 0;
        right: 0;
        width: 32px;
        height: 32px;
        color: transparent;
        overflow: hidden;
        background-image: url("/close-m.svg");
        background-size: 20px 20px;
        background-repeat: no-repeat;
        background-position: center;
        border: none;
        border-radius: 16px;
        background-color: transparent;
        margin: 0;
      }

      >.close-popup:hover {
        background-color: #eee;
        cursor: pointer;
      }

      >h4 {
        width: 100%;
        margin: 0px;
        font-size: 14px;
        padding-left: $topbar-popup-padding;
        line-height: 32px;
        border-bottom: 1px solid #ccc;
        margin-bottom: 16px;

        @media #{$mobile} {
          font-size: 14pt;
        }
      }

      >* {
        margin-left: $topbar-popup-padding;
        margin-right: $topbar-popup-padding;
      }

      >*:last-child {
        margin-bottom: $topbar-popup-padding;
      }
    }

    @media #{$desktop} {
      // Adds a small white arrow pointing at the element this popup "descends" from.
      position: fixed;
      top: 32px;

      &::before {
        content: " ";
        position: absolute;
        top: -8px;

        width: 0;
        height: 0;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-bottom: 8px solid white;
      }

      &.align-left::before {
        left: 41px;
      }

      &.align-right::before {
        right: 41px;
      }
    }

    @media #{$mobile} {
      position: static;
      margin: 64px auto 32px;
      font-size: 20px;
      max-width: 90%;
      border: 1px solid #ccc;
      overflow-y: auto;
    }

    &.centered {
      @media #{$desktop} {
        margin: 0px auto;
        width: 600px;
        margin-left: calc(50% - 300px);
      }
    }
  }

  &.share {
    .contact-box {
      position: relative;
      display: inline-block;
      width: 320px;
      border: 1px solid #e4e4e4;
      >ul.completed-contacts {
        list-style: outside none none;
        padding: 0px;
        display: inline;
        >li {
          display: inline-block;
          background-color: $sandstorm-purple-color;
          color: white;
          border-radius: 8px;
          padding: 2px 4px;
          border: 1px solid #e4e4e4;
          cursor: pointer;
          position: relative;

          &:focus, &:hover:focus {
            cursor: default;
            .closer {
              float: right;
              width: 16px;
              height: 16px;
              color: transparent;
              overflow: hidden;
              background-image: url("/close-m.svg");
              background-size: 12px 12px;
              background-repeat: no-repeat;
              background-position: center;
              border: none;
              border-radius: 8px;
              background-color: transparent;
              margin: 0px 0px 0px 4px;

              &:hover {
                background-color: #eee;
                cursor: pointer;
              }
            }
            background-color: lighten($sandstorm-purple-color, 30%);
          }
          &:hover {
            background-color: darken($sandstorm-purple-color, 10%);
          }
          .picture {
            width: 14px;
            height: 14px;
            background-size: contain;
            background-repeat: no-repeat;
            display: inline-block;
            margin-right: 4px;
           }
        }
      }
      >ul.autocomplete-suggestions {
        position: absolute;
        width: 350px;
        display: block;
        background: white;
        z-index: 1;
        border: 1px solid #e4e4e4;

        list-style: outside none none;
        padding: 0px;
        margin: 2px 0px;
        overflow-y: auto;
        max-height: 200px;
        >li {
          display: block;
          border: 1px solid rgba(0, 0, 0, 0);
          border-bottom: 1px solid #e4e4e4;
          cursor: pointer;

          &.selected {
            border: $focus-outline-color solid 1px;
          }
          &:hover {
            background-color: #999;
            * {
              background-color: #999;
            }
          }
        }
      }

      input.emails {
        border: 0px;
        outline: 0px;
        width: 100%;
      }
      &.active {
        outline: $focus-outline-color solid 1px;
      }
    }
  }

  &.share>.frame-container {
    width: 400px;
  }
  &.webkey>.frame-container {
    width: 450px;
  }

  &.share>.frame-container>.frame, &.who-has-access>.frame-container>.frame {
    $popup-background-color: #ededed;

    >h4 {
      text-transform: uppercase;
      background-color: $popup-background-color;
      margin-bottom: 0;
      padding: $topbar-popup-padding 20px;
    }

    >h4.share-with-others {
      border-bottom: none;
      padding-bottom: 30px;
    }
    >h4.who-has-access {
      padding-bottom: $topbar-popup-padding;
      border-bottom: 1px solid #ccc;
    }

    button.who-has-access {
      @include unstyled-button();
    }

    .share-tabs {
      width: 100%;
      padding: $topbar-popup-padding;
      border-top: 1px solid #ccc;
      position: relative;
      margin: 0;
      >ul {
        list-style: none;
        >li {
          border-top-left-radius: 4px;
          border-top-right-radius: 4px;
          background-color: #f7f7f7;
          border: 1px solid #ccc;
          border-bottom: none;
          position: absolute;
          margin: 0;
          padding: 3px;
          width: 45%;
          text-align: left;
          font-size: 14px; // Size must be the same on mobile and desktop for correct absolute position.
          top: -26px;
          height: 25px;
          background-position: 15px 2px, left;
          background-size: 20px, 20px;
          background-repeat: no-repeat;
          cursor: pointer;
          &:focus {
            outline: $focus-outline-color solid 1px;
          }
        }
        #send-invite-tab-header {
          left: 2%;

          &::before {
            @extend .icon;
            font-size: 18px;
            padding: 0 8px 2px 12px;
          }
          @extend .icon-email;
        }
        #shareable-link-tab-header {
          right: 2%;

          &::before {
            @extend .icon;
            font-size: 20px;
            padding: 0 8px 2px 12px;
          }
          @extend .icon-link;
        }
        [aria-selected=true] {
          background-color: white;
          border-bottom: 1px solid white;
          height: 26px;
        }
      }
      >div.tabpanel {
        margin-left: 16px;
        margin-right: 16px;
        &[aria-hidden=true] {
          display: none;
        }
      }
    }

    button.reset-invite, button.reset-share-token, button.start-over-invite {
      @include unstyled-button();
      border: 1px solid #ccc;
      border-radius: 4px;
      padding: 5px 16px;
      font-size: 10pt;
      text-transform: uppercase;
    }

    .button-container {
      display: flex;
      justify-content: space-between;
      margin-top: 10px;
    }
    .share-tabs form button {
      @extend %button-base;
      @extend %button-primary;
      border: 1px solid #ccc;
      border-radius: 4px;
      padding: 5px 16px;
      font-size: 10pt;
      text-transform: uppercase;
      margin-left: auto;
    }
    .share-token-role {
      width: 40%;
    }
    table .share-token-role {
      max-width: 160px;
    }
    div.tables-container {
      position: relative;
      overflow-y: auto;
      overflow-x: hidden; // A vertical scrollbar can cause horizontal overflow.
      max-height: calc(100vh - 130px);
      // HACK. This should be computed from the max-height of the containing div. Is that even
      // possible?
    }
    table.people, table.shared-links, table.grains {
      border: 1px solid #ddd;
      border-right: none;
      border-left: none;
      font-size: 10pt;
      width: 100%;
      border-collapse: collapse;
      tr {
        border-bottom: 1px solid #ddd;
      }
      ul {
         margin: 0;
      }
    }
    [data-obsolete=true] {
      display: none;
    }

    select {
      background-color: white;
      height: 25px;
      text-transform: uppercase;
      float: right;
    }
    input, textarea, select {
      border: 1px solid #aaa;
      padding: 4px;
      border-radius: 2px;
      vertical-align: top;
    }

    .label, .personal-message {
      width: 100%;
    }
    .personal-message {
      height: 100px;
    }
    .demo-mode-alert {
      color: #a94442;
      background-color: #f2dede;
      border-color: #ebccd1;
      padding: 5px;
      margin: 0;
      font-size: 10pt;
    }
    textarea.personal-message, input.emails, select.share-token-role {
      &[disabled=true] {
        background-color: #eaeaea;
      }
    }

    .invitation-explanation {
      max-width: 80%;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .invitation-explanation, .label-explanation {
      font-size: 8pt;
      font-style: italic;
    }

    .icon-people {
      font-size: 20px;
    }

    >.footer {
      width: 100%;
      background-color: $popup-background-color;
      border-top: 1px solid #ccc;
      margin: 0px;
      padding-top: 5px;
      padding-bottom: $topbar-popup-padding;
      text-align: right;
      font-size: 10pt;
      >.who-has-access {
        margin-right: 15px;
      }
    }
  }

  &.notifications {
    >.frame-container {
      width: 400px;
      >.frame>h4 {
        margin: 0;
      }

      // TODO(soon): This makes the little triangle pointing at the top bar disappear. :(
      overflow: auto;
    }

    ul.notification-list {
      list-style: outside none none;
      padding: 0px;
      margin: 0;
      &:last-child {
        margin: 0;
      }

      >li {
        border-bottom: 1px solid #ccc;
        &:last-child {
          border-bottom: 0px;
        }
      }

      .notification-item {
        display: block;
        font-size: 14px;
        text-decoration: inherit;
        font-weight: inherit;
        color: inherit;

        padding-left: $topbar-popup-padding + $topbar-popup-padding + 64px;
        padding-right: $topbar-popup-padding;
        padding-top: $topbar-popup-padding;
        padding-bottom: $topbar-popup-padding;

        position: relative;

        // Guarantee position-absolute icons don't get cut off
        min-height: $topbar-popup-padding + $topbar-popup-padding + 64px;

        &.urgent {
          background-color: $error-background-color;
        }

        &[href]:hover {
          background-color: #eee;
        }

        >.notification-icon {
          width: 64px;
          height: 64px;
          position: absolute;
          top: $topbar-popup-padding;
          left: $topbar-popup-padding;

          >img {
            display: block;
            position: absolute;
            width: 24px;
            height: 24px;
            right: 0;
            bottom: 0;
          }
          >img:first-of-type {
            width: 100%;
            height: 100%;
          }
        }

        >p {
          white-space: pre;
          margin: 0px;
        }

        .app-updates {
          list-style-type: none;
          padding: 0px;
        }

        .notification-footer {
          position: relative;
          margin-top: 12px;
          min-height: 18px;

          .notification-timestamp {
            position: absolute;
            left: 0px;
            top: 0px;
            text-align: left;
            color: #aaa;
          }
        }
      }
    }

    .notification-selected button {
      background-color: #666;
    }

    .notification-title {
      margin-bottom: 14px;
    }
  }

  &.backup {
    >.frame-container {
      width: 400px;
    }

    .warning-intro, .error {
      color: #a94442;
      background-color: #f2dede;
      border-color: #ebccd1;
      padding: 5px;
    }

    .button-row {
      display: flex;
      justify-content: flex-end;

      button {
        @extend %button-base;
        &[name=confirm] {
          @extend %button-primary;
        }
        &[name=cancel] {
          @extend %button-secondary;
        }
      }

      .spinner {
        width: 32px;
        height: 32px;
        background-image: url("/spinner_96.gif");
        background-size: 32px 32px;
      }
    }
  }
}
